<template>
  <div class="child">
    <h2>我是Child</h2>
    <h4>我的玩具：{{toy}}</h4>
    <button @click="handleClick">把玩具给父</button>
  </div>
</template>

<script>
  export default {
    name:'Child',
    data() {
      return {
        toy:'奥特曼'
      }
    },
    methods: {
      handleClick(){
        // 触发Child组件实例(vc)身上的haha事件
        this.$emit('send-toy',this.toy)
      }
    },
  }
</script>

<style>
  .child {
    background-color: skyblue;
    border-radius: 10px;
    box-shadow: 0 0 10px;
    padding: 20px;
  }
</style>